package com.lineage.data.item_etcitem.wand;

import com.lineage.data.executor.ItemExecutor;
import com.lineage.server.Instance.character.CharacterPunishInstance;
import com.lineage.server.model.Instance.L1ItemInstance;
import com.lineage.server.model.Instance.L1PcInstance;
import com.lineage.server.serverpackets.S_SystemMessage;
import com.lineage.server.serverpackets.ServerBasePacket;
import com.lineage.server.world.World;

public class PunishWand extends ItemExecutor {
  public static ItemExecutor get() {
    return new PunishWand();
  }
  
  public void execute(int[] data, L1PcInstance pc, L1ItemInstance item) {
    if (!pc.isGm())
      return; 
    int chartId = data[0];
    Object object = World.get().findObject(chartId);
    if (object == null)
      return; 
    if (object instanceof L1PcInstance) {
      L1PcInstance targetPc = (L1PcInstance)object;
      if (CharacterPunishInstance.get().checkCharacter(Integer.valueOf(chartId)).booleanValue()) {
        CharacterPunishInstance.get().removeCharacter(targetPc);
        pc.sendPackets((ServerBasePacket)new S_SystemMessage(String.format("玩家- %s 解除惩罚", new Object[] { targetPc.getName() })));
      } else {
        CharacterPunishInstance.get().addCharacter(targetPc);
        pc.sendPackets((ServerBasePacket)new S_SystemMessage(String.format("玩家- %s 进行惩罚", new Object[] { targetPc.getName() })));
      } 
    } 
  }
}
